{% extends "base.html" %}
{% block pagetitle %}Create Request{% endblock %}
{% block content %}

<script type="text/javascript"><!--
function updateRequestStateDone(responseText) {
  var json_return = parseJsonText(responseText);
  if (json_return['status'] != 'OK') {
    alert('operation failed: ' + json_return['message']);
  } else {
    alert('Success');
    document.getElementById('pledge_state').value = json_return['state'];
  }
}

function handleApprove(form) {
  ajaxUpdateForm(form, '', 'updateRequestStateDone');
}
//--></script>

<br>
<br>
<div class=art-box>
<h3>Donator:</h3>
{{ pledge.donor_profile.name }}
<br><br>
<h3>Amount: </h3>
  <input type="text" name="amount" disabled="1" value="{{ pledge.amount }}">RMB</input><br>
<br><br>
<h3>Description:</h3>
  <textarea rows=10 disabled="1" name="description">{{ pledge.description }}</textarea>
<br><br>
<h3>State:</h3>
  <input type="text" disabled="1" name="pledge_state" id="pledge_state" value="{{ pledge.state }}"></input><br><br>
  <form action="createpledge" method="post">
    <input type="hidden" name="pid" value="{{ pledge.key }}"></input>
    <input type="hidden" name="post_action" value="Action.approve"></input>
    <select id="state" name="state">
      <option value="0">OPEN</option>
      <option value="1">CLOSED</option>
    </select>
    <input type="button" name="approve" value="Change State" onclick="javascript:handleApprove(this.form)"></input>
  </form>
  <br><br>
</div>
{% endblock %}
